package com.example.seed.service;

import com.example.seed.entity.SysPermission;
import com.example.seed.entity.Tables;
//import com.example.seed.fliter.DataScopeFilter;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.List;

public interface SysPermissionRepository extends JRepository<SysPermission, Long> {
    default List<String> findPermissionSignByUserId(Long userId) {


        return sql()
                //.filters(it -> it.disableByTypes(DataScopeFilter.class))
                .createQuery(Tables.SYS_PERMISSION_TABLE)
                .whereIf(
                        userId != null,
                        () -> Tables.SYS_PERMISSION_TABLE
                                .sysRoles(role -> role.sysUsers(user -> user.id().eq(userId))))
                .select(Tables.SYS_PERMISSION_TABLE.sign()).execute();
    }
}
